package com.assets.Adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.assets.R;

import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2019/5/7.
 */

public class Fragment3_Adap extends BaseAdapter {
    private List<Map<String, Object>> data;
    private LayoutInflater layoutInflater;
    private Context context;
    public Fragment3_Adap(Context context, List<Map<String, Object>> data) {
        //传入的data，就是我们要在listview中显示的信息
        this.context = context;
        this.data = data;
        this.layoutInflater = LayoutInflater.from(context);
    }
    public class Info {
        public TextView odd_tv;//单号
        public TextView receivesDept_name;//领用部门
        public TextView receivesUser_name;//领用人
        public TextView receivesDate_name;//领用时间
        public TextView sum_name;//数量
        public TextView receivesDept;//领用部门
        public TextView receivesUser;//领用人
        public TextView odd;//单号
        public TextView receivesDate;//领用时间
        public TextView sum;//盘点总数

    }
    @Override
    public int getCount() {
        return data.size();
    }

    @Override
    public Object getItem(int position) {
        return data.get(position).get("odd");
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        Info info = new Info();
        convertView = layoutInflater.inflate(R.layout.fragment3_adap, null);
        info.odd_tv = (TextView) convertView.findViewById(R.id.odd_tv);
        info.receivesDept_name = (TextView) convertView.findViewById(R.id.receivesDept_name);
        info.receivesUser_name = (TextView) convertView.findViewById(R.id.receivesUser_name);
        info.receivesDate_name = (TextView) convertView.findViewById(R.id.receivesDate_name);
        info.sum_name = (TextView) convertView.findViewById(R.id.sum_name);
        info.odd = (TextView) convertView.findViewById(R.id.odd);
        info.receivesDept = (TextView) convertView.findViewById(R.id.receivesDept);
        info.receivesUser = (TextView) convertView.findViewById(R.id.receivesUser);
        info.receivesDate = (TextView) convertView.findViewById(R.id.receivesDate);
        info.sum = (TextView) convertView.findViewById(R.id.sum);
        //设置数据
        info.odd_tv.setText((String) data.get(position).get(
                "odd_tv"));
        info.receivesDept_name.setText((String) data.get(position).get(
                "receivesDept_name"));
        info.receivesUser_name.setText((String) data.get(position).get(
                "receivesUser_name"));
        info.receivesDate_name.setText((String) data.get(position).get(
                "receivesDate_name"));
        info.sum_name.setText((String) data.get(position).get(
                "sum_name"));




        info.odd.setText((String) data.get(position).get(
                "odd"));
        info.receivesDept.setText((String) data.get(position).get(
                "receivesDept"));
        info.receivesUser.setText((String) data.get(position)
                .get("receivesUser"));
        info.receivesDate.setText((String) data.get(position)
                .get("receivesDate"));
        info.sum.setText((String) data.get(position)
                .get("sum"));
        return convertView;
    }
}
